<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/8/9
  Time: 0:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <title>列表页面</title>
    <style>
        table tr:nth-child(odd){
            background: #ccc;
        }
    </style>
</head>
<body>
<h1 align="center">新能源汽车动力电池信息</h1>
<table align="center" border="2px">
    <tr>
        <th>编号</th>
        <th>车型</th>
        <th>所属城市</th>
        <th>使用单位</th>
        <th>压差报警值</th>
        <th>报警时间</th>
        <th>操作</th>
    </tr>
    <c:forEach var="list" items="${sessionScope.list}">
        <tr>
            <td><a href="Select?id=${list.id}">${list.id}</a></td>
            <td>${list.carname}</td>
            <td>${list.cityname}</td>
            <td>${list.username}</td>
            <td>${list.pressurevalue}</td>
            <td>${list.time}</td>
            <td><a href="#" onclick="Delet(${list.id})">删除</a> </td>
        </tr>
    </c:forEach>
</table>
</body>
<script>
    function Delet(id) {
        let b = confirm("确定要删除吗?");
        if (b){
            $.getJSON("Delete",{"id":id},function (data) {
                if (data==true){
                    alert("删除成功")
                }
                location.href="index.jsp";
            });
        }
    }
</script>
</html>
